package io.mft.commons.config.datasource;

import java.util.Collection;
import java.util.HashMap;

import io.mft.commons.util.Unique;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class DSConfig extends HashMap<String, DSConfigSource> implements Unique{
	 
	        /**
	 * @说明：TODO
	 * @字段名称 serialVersionUID
	        */  
	    
	private static final long serialVersionUID = -3200097453742405837L;
	//private ARDSConfigSource ar;
	//private DSConfigSource db;
	//private DSConfigSource redis;
	//private DSConfigSource rabbitmq;
	//private DSConfigSource kafka;
	//private Map<String, DSConfigSource> configs=new HashMap<String, DSConfigSource>();
	public void init() {
		keySet().forEach(key->{
			DSConfigSource dsConfigSource=get(key);
			dsConfigSource.setOwnerPluginId(key);
			dsConfigSource.setType(key);
			dsConfigSource.getDatasources().forEach(d->{
				d.setOwnerPluginId(key);
			});
		});
	}
	@Override
	public String uniqueId() {
		String id="";
		Collection<DSConfigSource> configs=values();
		for (DSConfigSource dsConfigSource : configs) {
			id=id+"-"+dsConfigSource.uniqueId();
		}
		return id;
	}
}
